/**
 * 
 */
package uniandes.moviles.antid.interfaz;

import uniandes.moviles.antid.R;
import uniandes.moviles.antid.mundo.Patient;
import uniandes.moviles.antid.mundo.PersistenceManager;
import uniandes.moviles.antid.mundo.Professional;
import uniandes.moviles.antid.mundo.User;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

/**
 * @author Julio Mendoza
 * Represents the register activity.
 */
public class RegisterActivity extends Activity 
{
	/**
	 * Manages the persistence of the application.
	 */
	private PersistenceManager manager;
	
	/**
	 * Data confirmation button object.
	 */
	private Button btnGo;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lyregister);
        manager = new PersistenceManager(this);
        inicializarBotones();
    }

	private void inicializarBotones() {
		btnGo = (Button)findViewById(R.id.btnGo);
		btnGo.setOnClickListener( new View.OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				try 
				{
					register();
				}
				catch (Exception e) 
				{
					
				}
				
			}
		});
		
	}
	
	private void register()
	{
		User user = null;
		Spinner spinner = (Spinner)findViewById(R.id.spRoles);
		String lblRole = (String)spinner.getSelectedItem();
		if(lblRole.startsWith("Pa"))
		{
			user = new Patient(manager);
		}
		else
		{
			user = new Professional(manager);
		}
		EditText txtName = (EditText)findViewById(R.id.txtName);
		
	}
	
}
